/**
 * @Description
 * @author 20155870 杨润增
 * @create 2018-05-21 9:00
 **/
package com.academic_system.util;


import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @className DateJsonType
 * @Description 返回json串中含有Date类型，格式化Date显示格式
 **/
public class DateJsonType extends JsonSerializer<Date> {
    @Override
    public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException {
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
        jsonGenerator.writeString(formatter.format(date));
    }

}
